package com.example.administrator.hello;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private EditText firstET,seconET;
    private Button calcBtn;
    private TextView result;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        firstET=(EditText)findViewById(R.id.first);
        seconET=(EditText)findViewById(R.id.second);
        calcBtn= (Button) findViewById(R.id.calc);
        result=(TextView) findViewById(R.id.result);

        calcBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String firstValue=firstET.getText().toString();
                String secondValue=seconET.getText().toString();
                int finalResult=Integer.parseInt(firstValue)+Integer.parseInt(secondValue);
                result.setText(finalResult+"");
                result.setVisibility(View.VISIBLE);


            }
        });
    }
}
